package com.peng.leetcode.tree;

/**
 * NumTrees
 * 96. 不同的二叉搜索树
 * https://leetcode.cn/problems/unique-binary-search-trees/
 *
 * @author: lupeng6
 * @create: 2023/2/20 13:10
 */
public class NumTrees {

    public static void main(String[] args) {
        System.out.println(new NumTrees().numTrees(4));
    }

    public int numTrees(int n) {
        if (n == 0 || n == 1) {
            return 1;
        }
        int count = 0;
        for (int i = 1; i <= n; i++) {
            int l = numTrees(i - 1);
            int r = numTrees(n - i);
            count += l * r;
        }
        return count;
    }

}
